package de.baumann.browser.present

import de.baumann.browser.api.OdinObserver
import de.baumann.browser.api.net.vo.InviteInfo
import de.baumann.browser.iview.InviteView
import de.baumann.browser.model.UserModel

class InvitePresenter : CanCreatePoolPresenter<InviteView>() {
    private val userModel = UserModel()

    fun getSpreadInfos() {
        this.userModel.spreadInfos
                .subscribe(object : OdinObserver<InviteInfo>() {
                    override fun onSuccess(data: InviteInfo?) {
                        if (view != null && data != null) {
                            data.all_invite?.let {
                                view.setInviteCount(it)
                            }

                            data.contribute?.let {
                                view.setContribute(it)
                            }

                            data.list?.let {
                                view.setInviteList(it)
                            }
                        }
                    }
                })
    }
}